#include "yolov8_pose.h"
#include <opencv2/opencv.hpp>

int main()
{
    std::string modelPath = "E:/Work/model/yolopose/yolov8n-pose.onnx";
    std::string imgStr = "F:/Dataset/CrowdPose/images/100075.jpg";
    std::unique_ptr<Yolov8Pose> v8Pose = std::make_unique<Yolov8Pose>();

    std::vector<int> padding;
    cv::Mat letterimg;
    cv::Mat frame = cv::imread(imgStr);
    v8Pose->LoadModel("Yolov8Pose", modelPath);

    float scale = v8Pose->LetterBox(frame, letterimg, padding, cv::Size(640, 640), cv::Scalar(114, 114, 114), true);
    // std::cout << padding.size() << std::endl;
    std::vector<PoseInfo> result = v8Pose->Inference(letterimg, scale, padding);
    // std::cout << "testing" << std::endl;
    int i = 0;
    for (const auto &result_info : result)
    {
        PoseBox box = result_info.bbox;
        cv::rectangle(frame, cv::Rect(box.x, box.y, box.w, box.h), cv::Scalar(0, 255, 0));
        std::vector<PosePoint> kpts = result_info.poseV;

        for (const auto &point : kpts)
        {
            cv::putText(frame, std::to_string(i), cv::Point(int(point.x), int(point.y) + 10), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255), 1);
            cv::circle(frame, cv::Point(int(point.x), int(point.y)), 2, cv::Scalar(0, 128, 255));
            i += 1;
        }
    }

    cv::imshow("test", frame);
    cv::waitKey(0);

    return 0;
}